package templateExcel;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

//处理文件
public class FileUtils {

    //文件复制
    public static boolean copy(File src, File to) {

        try {

            if (!to.exists()) {
                try {
                    to.createNewFile();
                } catch (IOException ignore) {
                }
            }

            FileInputStream inputStream = new FileInputStream(src);
            FileChannel inputStreamChannel = inputStream.getChannel();

            FileOutputStream outputStream = new FileOutputStream(to);
            FileChannel outputStreamChannel = outputStream.getChannel();

            inputStreamChannel.transferTo(0, src.length(), outputStreamChannel);

            inputStream.close();
            outputStream.close();
            inputStreamChannel.close();
            outputStreamChannel.close();

            return true;
        } catch (Exception e) {
            return false;
        }


    }

}
